翻訳と辞書
Words near each other
・ Typeface (film)
・ Typeface anatomy
・ Typeful programming
・ Typekit
・ TypeMatrix
・ Typename
・ Typenturm
・ Typeof
・ TypePad
・ TypeParameter
・ TypeRacer
・ Types and Programming Languages
・ Types of abortion restrictions in the United States
・ Types of artificial neural networks
・ Types of Bakuvian Bazaars
Type class
・ Type code
・ Type color
・ Type constructor
・ Type Control
・ Type conversion
・ Type D escort ship
・ Type D personality
・ Type D submarine
・ Type Description Language
・ Type design
・ Type Directors Club
・ Type enforcement
・ Type erasure
・ Type family


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Type class : ウィキペディア英語版
Type class

In computer science, a type class is a type system construct that supports ad hoc polymorphism. This is achieved by adding constraints to type variables in parametrically polymorphic types. Such a constraint typically involves a type class T and a type variable a, and means that a can only be instantiated to a type whose members support the overloaded operations associated with T.
Type classes first appeared in the Haskell programming language,〔"Type classes, first proposed during the design of the Haskell programming language, ..." —(John Garrett Morris (2013), "Type Classes and Instance Chains: A Relational Approach" )〕 and were originally conceived as a way of implementing overloaded arithmetic and equality operators in a principled fashion.
In contrast with the "eqtypes" of Standard ML, overloading the equality operator through the use of type classes in Haskell does not require extensive modification of the compiler frontend or the underlying type system.
Since their creation, many other applications of type classes have been discovered.
== Overview ==
The programmer defines a type class by specifying a set of function or constant names, together with their respective types, that must exist for every type that belongs to the class. In Haskell, types can be parameterized; a type class Eq intended to contain types that admit equality would be declared in the following way:

class Eq a where
(==) :: a -> a -> Bool
(/=) :: a -> a -> Bool

This declaration may be read as stating a "type a belongs to type class Eq if there are functions named (==), and (/=), of the appropriate types, defined on it." A programmer could then define a function elem (which determines if an element is in a list) in the following way:

elem :: (Eq a) => a -> () -> Bool
elem y , that is, lists of elements of type t.
Note that type classes are different from classes in object-oriented programming languages. In particular, Eq is not a type: there is no such thing as a ''value'' of type Eq.
Type classes are closely related to parametric polymorphism. For example, note that the type of elem as specified above would be the parametrically polymorphic type a -> () -> Bool were it not for the type class constraint "(Eq a) =>".

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Type class」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.